package com.heng.test.BigDecimal;

public class doubleDemo {
    public static void main(String[] args) {
        double num = 13.5;
        long bits = Double.doubleToLongBits(num);
        String binary = Long.toBinaryString(bits);
        // 补齐 64 位
        binary = String.format("%64s", binary).replace(' ', '0');
        System.out.println("符号位: " + binary.substring(0, 1));
        System.out.println("指数位: " + binary.substring(1, 12));
        System.out.println("尾数位: " + binary.substring(12));
    }
}
